home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- //
- // Description:
- // This script is defines the option box for the boundary menu item.
- //
-
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists boundaryOrder`) {
- optionVar -intValue boundaryOrder 0;
- }
- if ($forceFactorySettings || !`optionVar -exists boundaryInsist`) {
- optionVar -intValue boundaryInsist 0;
- }
- if ($forceFactorySettings || !`optionVar -exists boundaryPartial`){
- optionVar -intValue boundaryPartial 0;
- }
- if ($forceFactorySettings || !`optionVar -exists boundaryPolys`){
- optionVar -intValue boundaryPolys 0;
- }
- if ($forceFactorySettings ||
- !`optionVar -exists boundaryUseGlobal`) {
- optionVar -intValue boundaryUseGlobal 1;
- }
- if ($forceFactorySettings ||
- !`optionVar -exists boundaryTolerance`) {
- optionVar -floatValue boundaryTolerance 0.01;
- }
- if ($forceFactorySettings ||
- !`optionVar -exists boundaryAutoEdgeCount`) {
- optionVar -iv boundaryAutoEdgeCount 4;
- }
- }
-
- //
- // Procedure Name:
- // boundaryVisibility
- //
- // Description:
- // Depending on the options, some other options do or do not show.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- // Return Value:
- // None.
- //
-
- global proc boundaryVisibility( string $parent,
- int $useGlobal,
- int $insist,
- string $goToTool)
- {
- if( $useGlobal < 0 ) {
- $useGlobal = 2 - `radioButtonGrp -q -select useGlobalRadio`;
- }
- if( $insist < 0 ) {
- $insist = `radioButtonGrp -q -select insistRadio` - 1;
- }
-
- if( $insist ) {
- radioButtonGrp -e -en 1 useGlobalRadio;
- if( $useGlobal == 1 ) {
- floatSliderGrp -e -en 0 toleranceFloat;
- }
- else {
- floatSliderGrp -e -en 1 toleranceFloat;
- }
- }
- else {
- radioButtonGrp -e -en 0 useGlobalRadio;
- floatSliderGrp -e -en 0 toleranceFloat;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -en1 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget2;
- }
- }
-
- //
- // Procedure Name:
- // boundarySetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
-
- global proc boundarySetup( string $parent,
- int $forceFactorySettings,
- string $goToTool)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- boundaryToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Query the optionVar's and set the values into the controls
- //
- int $order = `optionVar -query boundaryOrder`;
- int $insist = `optionVar -query boundaryInsist`;
- int $partial = `optionVar -query boundaryPartial`;
- int $polys = `optionVar -query boundaryPolys`;
- if( ! `isTrue "SurfaceUIExists"` ) $polys = 1;
-
- int $useGlobal = `optionVar -query boundaryUseGlobal`;
- float $tolerance = `optionVar -query boundaryTolerance`;
-
- radioButtonGrp -edit -select ($order+1) orderRadio;
- radioButtonGrp -edit -select ($insist+1) insistRadio;
- radioButtonGrp -edit -select ($partial+1) partialRadio;
- radioButtonGrp -edit -select (2 - $useGlobal) useGlobalRadio;
- floatSliderGrp -edit -value $tolerance toleranceFloat;
-
- // set polygons | Nurbs option.
- //
- if( `isTrue "SurfaceUIExists"` ) {
- if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) {
- $polys = 2;
- }
- radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp;
- }
- switch( $polys ) {
- case 0:
- default:
- tabLayout -e -st polyOptionsNo polyOptions;
- break;
- case 1:
- tabLayout -e -st polyOptionsOK polyOptions;
- break;
- case 2:
- tabLayout -e -st polyOptionsSubdiv polyOptions;
- break;
- case 3:
- tabLayout -e -st polyOptionsBezier polyOptions;
- break;
- }
- nurbsToPolySetup( $parent, $forceFactorySettings );
- nurbsToSubdivSetup( $parent, $forceFactorySettings );
- boundaryVisibility( $parent, $useGlobal, $insist, $goToTool );
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v1 (4 == `optionVar -q boundaryAutoEdgeCount`)
- scriptToolExtraWidget2;
- }
- }
-
- //
- // Procedure Name:
- // boundaryCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
-
- global proc boundaryCallback( string $parent, int $doIt, string $goToTool )
- {
- if( "" != $goToTool ) {
- optionVar -iv boundaryEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv boundaryLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the current control values, and then perform
- // the command
- //
- int $order = `radioButtonGrp -q -select orderRadio` - 1;
- int $insist = `radioButtonGrp -q -select insistRadio` - 1;
- int $partial = `radioButtonGrp -q -select partialRadio` - 1;
- int $useGlobal = 2 - `radioButtonGrp -q -select useGlobalRadio`;
- float $tolerance = `floatSliderGrp -q -value toleranceFloat`;
-
- optionVar -intValue boundaryOrder $order;
- optionVar -intValue boundaryInsist $insist;
- optionVar -intValue boundaryPartial $partial;
- optionVar -intValue boundaryUseGlobal $useGlobal;
- optionVar -floatValue boundaryTolerance $tolerance;
-
- if( `isTrue "SurfaceUIExists"` ) {
- int $polys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
- if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) {
- $polys = 4;
- }
- optionVar -intValue boundaryPolys ($polys-1);
- }
-
- nurbsToPolyCallback( $parent, 0 );
- nurbsToSubdivCallback( $parent, 0 );
-
- if( 1 == $doIt ) {
- performBoundary( 0, $goToTool );
- string $tmpCmd = "performBoundary( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Boundary";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // boundaryOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc boundaryOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "boundary";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Step 1: Get the option box.
- // ============================
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolBoundary";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "boundaryToolScript 3";
-
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp -nrb 2 -l "Curve Ordering"
- -l1 "Automatic"
- -l2 "As Selected"
- orderRadio;
-
- radioButtonGrp -nrb 2 -l "Common End Points"
- -l1 "Optional"
- -l2 "Required"
- insistRadio;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "End Point Tolerance"
- -label1 "Global"
- -label2 "Local"
- useGlobalRadio;
-
- floatSliderGrp -label "Tolerance"
- -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0
- toleranceFloat;
-
- separator;
-
- radioButtonGrp -numberOfRadioButtons 2
- -label "Curve Range"
- -label1 "Complete"
- -label2 "Partial"
- partialRadio;
-
-
- // Set the tolerance radio button up so that when "Global" is
- // selected, then the local tolerance slider is disabled.
- // When "Local" is selected then the local tolerance slider is enabled.
- //
- radioButtonGrp -edit
- -cc1 ("boundaryVisibility " + $parent + " 1 -1 \"" + $goToTool + "\"")
- -cc2 ("boundaryVisibility " + $parent + " 0 -1 \"" + $goToTool + "\"")
- useGlobalRadio;
-
- // Set the layout that contains the number of spans slider and
- // the degree slider so that only displays stuff when the type is Uniform.
- //
- radioButtonGrp -edit
- -cc2 ("boundaryVisibility " + $parent + " -1 1 \"" + $goToTool + "\"")
- -cc1 ("boundaryVisibility " + $parent + " -1 0 \"" + $goToTool + "\"")
- insistRadio;
-
- separator ;
-
- // output Geometry
- //
- if( `isTrue "SubdivUIExists"` ) {
- radioButtonGrp -numberOfRadioButtons 4
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Subdiv"
- -label4 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsSubdiv polyOptions"
- -cc4 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
- else if( `isTrue "SurfaceUIExists"` ) {
- radioButtonGrp -nrb 3
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
-
- tabLayout -tabsVisible false polyOptions;
- string $par = `columnLayout polyOptionsOK`;
- nurbsToPolyAddOptions $par;
- setParent ..;
- columnLayout polyOptionsNo;
- setParent ..;
- columnLayout polyOptionsSubdiv;
- nurbsToSubdivAddOptions $par;
- setParent ..;
- columnLayout polyOptionsBezier;
- setParent ..;
- setParent ..;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("boundaryAutoComplete 1 " +
- "\"" + $goToTool + "\";" +
- "boundaryVisibility " + $parent + " 1 -1 \"" +
- $goToTool + "\"")
- -of2 ("boundaryAutoComplete 0 " +
- "\"" + $goToTool + "\";" +
- "boundaryVisibility " + $parent + " 1 -1 \"" +
- $goToTool + "\"")
- scriptToolExtraWidget;
-
- checkBoxGrp -ncb 1 -l ""
- -l1 "4 Boundary Curves"
- -v1 off
- -on1 ("boundary4curves 4 " + $goToTool +
- "; optionVar -iv boundaryAutoEdgeCount 4")
- -of1 ("boundary4curves 3 " + $goToTool +
- "; optionVar -iv boundaryAutoEdgeCount 3")
- scriptToolExtraWidget2;
- }
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Boundary Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"" )
- $applyBtn;
- }
- else {
- button -edit -l "Boundary"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"" )
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Boundary Tool Options");
- }
- else {
- setOptionBoxTitle("Boundary Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "Boundary" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // boundaryHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
-
- proc string boundaryHelp()
- {
- return
- " Command: Boundary - create boundary surface from 3 or 4 curves.\n" +
- "Selection: curves, surface isoparms, curve on surface, surface edges";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "performBoundaryPreset";
-
- setOptionVars(false);
-
- int $doHistory = `constructionHistory -q -tgl`;
- int $order = `optionVar -q boundaryOrder`;
- int $insist = `optionVar -q boundaryInsist`;
- int $partial = `optionVar -q boundaryPartial`;
- int $polys = `optionVar -q boundaryPolys`;
- if( ! `isTrue "SurfaceUIExists"` ) $polys = 1;
- int $useGlobal = `optionVar -q boundaryUseGlobal`;
- float $globalTol = `optionVar -q positionalTolerance`;
- float $localTol = `optionVar -q boundaryTolerance`;
-
- $cmd = ( $cmd + " " +
- $doHistory + " " +
- $order + " " +
- $insist + " " +
- $partial + " " +
- $polys + " " +
- $useGlobal + " " +
- $globalTol + " " +
- $localTol );
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performBoundary
- //
- // Description:
- // Perform the boundary command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the boundary command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- // 3 - Show the tool option box dialog.
- //
- // Return Value:
- // None.
- //
-
- global proc string performBoundary( int $action, string $goToTool )
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
- case 1:
- boundaryOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-